/**
 * 
 */
package com.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;


/**
 * 投票Model类。
 * @author Danny Tam
 *
 */
@Entity
public class Vote {
	/**
	 *  投票状态 - 初始
	 */
	public static char VOTE_STATUS_I = 'I';
	/**
	 *  投票状态 - 开始
	 */
	public static char VOTE_STATUS_S = 'S';
	/**
	 *  投票状态 - 结束
	 */
	public static char VOTE_STATUS_E = 'E';
	/**
	 *  投票状态 - 删除
	 */
	public static char VOTE_STATUS_D = 'D';
	
	/**
	 * 投票结果显示模式。<br>
	 * <strong>SHOW_BEFORE_VOTE</strong> : 投票前可见<br>
	 * <strong>SHOW_AFTER_VOTE</strong>  : 投票后可见<br>
	 * <strong>SHOW_END_OF_VOTE</strong> : 投票结束可见<br>
	 * @author Danny Tam
	 * 
	 */
	public enum SHOW_RESULT_MODEL {
		SHOW_BEFORE_VOTE,
		SHOW_AFTER_VOTE,
		SHOW_END_OF_VOTE
	}
	private Integer id; //主键
	private Keyword keyword; //关键字
	private String title; //标题
	private String imgUrl; //图片地址
	private boolean showInPage; //是否显示在投票页
	private String description; //投票说明
	private List<VoteOptions> voteOptionList; //投票选项
	private boolean singleSelect; //是否单选
	private Integer maxSelect;
	private String startTime;  //投票开始时间
	private String endTime;   //投票结束时间
	private SHOW_RESULT_MODEL showResultModel;
	private String type ; //投票类型（文字投票、图片投票）
	private char status; //状态标志（S-开始，E-结束，D-删除）
	private String createTime; //创建时间
	private String updateTime; //修改时间
	private String token;
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@OneToOne
	@JoinColumn(name="keyid", insertable=true, unique=true) 
	public Keyword getKeyword() {
		return keyword;
	}
	public void setKeyword(Keyword keyword) {
		this.keyword = keyword;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	public boolean isShowInPage() {
		return showInPage;
	}
	public void setShowInPage(boolean showInPage) {
		this.showInPage = showInPage;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	@OneToMany(mappedBy="vote", cascade=CascadeType.ALL, fetch=FetchType.EAGER) //设置了lazy = false
	public List<VoteOptions> getVoteOptionList() {
		return voteOptionList;
	}
	public void setVoteOptionList(List<VoteOptions> voteOptionList) {
		this.voteOptionList = voteOptionList;
	}
	public boolean isSingleSelect() {
		return singleSelect;
	}
	public void setSingleSelect(boolean singleSelect) {
		this.singleSelect = singleSelect;
	}
	public Integer getMaxSelect() {
		return maxSelect;
	}
	public void setMaxSelect(Integer maxSelect) {
		this.maxSelect = maxSelect;
	}
	public String getStartTime() {
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
	public String getEndTime() {
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	public SHOW_RESULT_MODEL getShowResultModel() {
		return showResultModel;
	}
	public void setShowResultModel(SHOW_RESULT_MODEL showResultModel) {
		this.showResultModel = showResultModel;
	}

	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public char getStatus() {
		return status;
	}
	public void setStatus(char status) {
		this.status = status;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
}
